﻿using System;
using System.IO;

public partial class App_Form_Upload_upload : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string b_qr = Request.QueryString["loai"];
        if (!string.IsNullOrEmpty(b_qr))
            loai.Value = b_qr;
    }
    protected void AsyncFileUpload1_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
    {
        if (AsyncFileUpload1.HasFile)
        {
            string b_tenf = AsyncFileUpload1.FileName.ToString();
            if (loai.Value == "")
            {
                if (File.Exists(Server.MapPath("~/images/" + b_tenf))) File.Delete(Server.MapPath("~/images/" + b_tenf));
                AsyncFileUpload1.PostedFile.SaveAs(Server.MapPath("~/images/" + b_tenf));
            }
            else
            {
                string tm = DateTime.Now.Year.ToString();
                string dd = Server.MapPath("~/VB/");
                dd = dd + tm;
                if (!Directory.Exists(dd))
                    Directory.CreateDirectory(dd);
                //Upda 
                dd = dd + "/" + b_tenf;
                if (File.Exists(dd)) File.Delete(dd);
                AsyncFileUpload1.PostedFile.SaveAs(dd);
            }
        }
    }
}